package receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;

import com.example.menhoo.menhoolibrary.R;
import com.example.menhoo.toollibrary.common.assist.Network;

/**
 * 网络状态监听广播
 * @author yanglei
 *
 */
public class AndroidNetConnectionChangeStateReceiver extends BroadcastReceiver{

	public static final String Action = ConnectivityManager.CONNECTIVITY_ACTION;
	@Override
	public void onReceive(Context context, Intent intent) {
		if (Action.equals(intent.getAction())){

			boolean isNetworkAvailable= Network.isConnected(context);
			String message=context.getString(R.string.no_available_network_content3);
			if(isNetworkAvailable){
				message=context.getString(R.string.available_network_title);
			}

			Intent it = new Intent();// 创建Intent对象
			it.setAction(NetStateReceiver.Action);
			it.putExtra("isNetworkAvailable",isNetworkAvailable);
			it.putExtra("message", message);
			context.sendBroadcast(it);
		}
		 
	}


}
